package com.william.taskrobot.controller;

import com.william.taskrobot.model.SessionInfo;
import com.william.taskrobot.service.BussnessService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * RobootController class
 *
 * @author william
 * @date 2021/1/15
 */
@RestController
@RequestMapping(value = "robot")
public class RobotController {
    @Autowired
    private BussnessService bussnessService;
    @RequestMapping(value = "answer")
    public String getAnswer(@RequestParam("question") String question,
                            @RequestParam(value = "sessionId",defaultValue = "0",required = false) Integer sessionId){
        try {
            return bussnessService.getAnswer(question, new SessionInfo());
        }
        catch (Exception ex){
            return StringUtils.EMPTY;
        }
    }
}
